package com.alibaba.travel.comment.controller;

import java.util.Arrays;
import java.util.Map;

import com.alibaba.travel.common.utils.PageUtils;
import com.alibaba.travel.common.utils.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.alibaba.travel.comment.dto.entity.UserCommentHistoryEntity;
import com.alibaba.travel.comment.service.UserCommentHistoryService;



/**
 * 用户评论历史表
 *
 * @author wherezy
 * @email wherezy@tom.com
 * @date 2023-02-23 15:11:40
 */
@Api(tags = {"用户评论历史表UserCommentHistoryController"})
@RestController
@RequestMapping("comment/usercommenthistory")
public class UserCommentHistoryController {
    @Autowired
    private UserCommentHistoryService userCommentHistoryService;

    /**
     * TODO 评论终极topic Type -- 跳转路径
     * 文章评论数
     */

    /**
     * 景点评论数
     */

    /**
     * 评论评论数
     */

    /**
     * 列表
     */
    @ApiOperation(value="分页获取信息", notes="k-v map形式封装分页参数")
    @PostMapping("/list")
    public R list(@RequestBody Map<String, Object> params){
        PageUtils page = userCommentHistoryService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @ApiOperation(value="获取信息")
    @GetMapping("/info/{id}")
    public R info(@PathVariable("id") Long id){
		UserCommentHistoryEntity userCommentHistory = userCommentHistoryService.getById(id);

        return R.ok().put("userCommentHistory", userCommentHistory);
    }

    /**
     * 保存
     */
    @ApiOperation(value="保存")
    @PostMapping("/save")
    public R save(@RequestBody UserCommentHistoryEntity userCommentHistory){
		userCommentHistoryService.save(userCommentHistory);

        return R.ok();
    }

    /**
     * 修改
     */
    @ApiOperation(value="修改")
    @PostMapping("/update")
    public R update(@RequestBody UserCommentHistoryEntity userCommentHistory){
		userCommentHistoryService.updateById(userCommentHistory);

        return R.ok();
    }

    /**
     * 删除
     */
    @ApiOperation(value="删除")
    @PostMapping("/delete")
    public R delete(@RequestBody Long[] ids){
		userCommentHistoryService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
